package common;

public class Timeline {
	private String timelineHTML;
	private Tweet[] timelineTweets;

	public Timeline(Tweet[] tweets) {
		this.timelineTweets = tweets;
		this.timelineHTML = "";
		int l = this.timelineTweets.length;
		for (int i = 0; i < l; i++) {
			this.timelineHTML += ("\n" + timelineTweets[i].toString());
		}
	}

	public void AddTweet(Tweet tweet) {
		int l = this.timelineTweets.length;
		Tweet[] newTweets = new Tweet[l + 1];
		newTweets[0] = tweet;
		for (int i = 1; i <= l; i++) {
			newTweets[i] = this.timelineTweets[i - 1];
		}
		Timeline newTimeline = new Timeline(newTweets);
		this.timelineTweets = newTimeline.timelineTweets;
		this.timelineHTML = newTimeline.timelineHTML;
	}

	public String toString() {
		return (this.timelineHTML);
	}

}
